package com.boxtelecom.users;

import java.util.ArrayList;

import android.util.Log;

public class RosterUser {

	private String _id;
	private String _user;
	private String _name;
	private Presence _presence;
	private boolean _newMessage;
	private boolean _firstNewMessage;
	private ArrayList<String> _listMessage;
	private int _color;
	
	public RosterUser() {
		_id = null;
		_user = null;
		_name = null;
		_presence = new Presence();
		_newMessage = false;
		_listMessage = null;
		_color = 0;
		_firstNewMessage = true;
	}
	
	public String getId() {
		return _id;
	}

	public void setId(String anId) {
		this._id = anId;
	}

	public String getUser() {
		return _user;
	}

	public void setUser(String anUser) {
		this._user = anUser;
	}

	public String getName() {
		return _name;
	}

	public void setName(String aName) {
		this._name = aName;
	}
	
	public Presence getPresence(){
		return _presence;
	}
	
	public void setPresence(String type, String mode){
		this._presence.setType(type);
		this._presence.setMode(mode);
	}
	
	public void setPresence(String type){
		this._presence.setType(type);
	}

	public boolean isNewMessage() {
		return _newMessage;
	}

	public void setNewMessage(boolean aNewMessage) {
		this._newMessage = aNewMessage;
	}

	public ArrayList<String> getListMessage() {
		return _listMessage;
	}

	public void setListMessage(ArrayList<String> aListMessage) {
		this._listMessage = aListMessage;
	}

	public int getColor() {
		return _color;
	}

	public void setColor(int aColor) {
		this._color = aColor;
	}

	public void addMessage(String aMessage) {
		// TODO Auto-generated method stub
		if(_listMessage == null){
			_listMessage = new ArrayList<String>();
		}
		_listMessage.add(aMessage);
	}

	public boolean isFirstNewMessage() {
		return _firstNewMessage;
	}

	public void setFirstNewMessage(boolean aFirstNewMessage) {
		this._firstNewMessage = aFirstNewMessage;
	}

	public void setIdFromUser(String user) {
		// TODO Auto-generated method stub
		int deb_id = user.indexOf("-");
		int fin_id = user.lastIndexOf("@");
		setId(user.substring(deb_id + 1, fin_id));
	}
	
	public void print(){
		Log.d("Roster", "id: " + getId());
		Log.d("Roster", "user: " + getUser());
		Log.d("Roster", "name: " + getName());
		Log.d("Roster", "presence:" + getPresence().getType());
	}	
}
